package org.example.Mapper;

import org.apache.ibatis.annotations.*;
import org.example.domain.Summary;

@Mapper
public interface SummaryMapper {

    @Delete("DELETE FROM summary WHERE userId=#{userId};")
    void deleteAllSummariesByUserId(Integer userId);

    @Insert("INSERT INTO summary (userId,activityId,content) VALUES (#{userId},#{activityId},#{content});")
    void addOneSummary(@Param("userId") Integer userId,@Param("activityId") Integer activityId,
                       @Param("content") String content);

    @Select("SELECT * FROM summary WHERE userId=#{userId} LIMIT #{start},10;")
    Summary[] getSummariesByUserId(Integer userId,Integer start);

    @Select("SELECT * FROM summary WHERE activityId=#{activityId} LIMIT #{start},10;")
    Summary[] getSummariesByActivityId(Integer activityId,Integer start);

    @Update("UPDATE summary SET status=1 WHERE id=#{id};")
    void changeStatusById(Integer id);
}